package ru.rchervot.sanasar.client.event;

import ru.rchervot.sanasar.client.model.UserSettings;

import com.google.gwt.event.shared.GwtEvent;

public class EventSettingsChange extends GwtEvent<HandlerSettingsChange> {
	private static Type<HandlerSettingsChange> TYPE = new Type<HandlerSettingsChange>();
	
	private final UserSettings settings;
	
	public EventSettingsChange() {
		settings = null;
	} //TODO why not remove ?
	
	public EventSettingsChange(UserSettings settings) {
		this.settings = settings;
	}
	
	@Override
	protected void dispatch(HandlerSettingsChange handler) {
		handler.onSettingsChange(this);
	}

	/**
	 * Gets the type associated with this event.
	 * 
	 * @return returns the handler type
	 */
	public static Type<HandlerSettingsChange> getType() {
		if (TYPE == null) {
			TYPE = new Type<HandlerSettingsChange>();
		}
		return TYPE;
	}

	public Type<HandlerSettingsChange> getAssociatedType() {
		return TYPE;
	}

	public UserSettings getSettings() {
		return settings;
	}
	
	public static EventSettingsChange build(UserSettings settings) {
		return new EventSettingsChange(settings);
	}

}
